from flask import session

from info.models import User
from . import news_blu
from flask import current_app,render_template


@news_blu.route("/")
def index():
    user = None
    user_id = session.get('user_id')
    if user_id:
            try:
                user = User.query.get(user_id)
            except Exception as e:
                current_app.logger.error(e)
    data = user.to_dict() if user else None
    return render_template('news/index.html', data=data)
@news_blu.route("/favicon.ico")
def favicon():
    return current_app.send_static_file('news/favicon.ico')